﻿using PlusAssistance.BL.Abstract;
using System.Web.Mvc;

namespace PlusAssistance.Controllers
{
    public class ImportDataController : Controller
    {
        private readonly IDataImportManager _dataImportManager;

        public ImportDataController(IDataImportManager dataImportManager)
        {
            this._dataImportManager = dataImportManager;
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ReadExcel(string sheetName)
        {
            var tempPath = Server.MapPath("~/Temp/");

            var excelFile = this.Request.Files[0];

            this._dataImportManager.ImportExcelXLS(excelFile, tempPath, sheetName);

            return RedirectToAction("Index", "Import");
        }

    }
}
